//
//  ViewController.m
//  111
//
//  Created by sks on 16/1/26.
//  Copyright © 2016年 tml. All rights reserved.
//

#import "ViewController.h"
#import "FirstViewController.h"
@interface ViewController ()

{
    UIButton *btn;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
        [btn setImage:[UIImage imageNamed:@"_26"] forState:UIControlStateSelected];

   
        [btn setImage:[UIImage imageNamed:@"_22@3x"] forState:UIControlStateNormal];
    
    
    btn.frame = CGRectMake(100, 100, 100, 100);
    [btn  addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
    
    UILabel *label = [[UILabel alloc] init];
    label.text = @"学无止境";
    label.frame = CGRectMake(220, 100, 100, 30);
    label.textColor = [UIColor yellowColor];
    [self.view addSubview:label];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)click{
    FirstViewController *firstVC = [[FirstViewController alloc]init];
    firstVC.title = @"11";
    [self.navigationController pushViewController:firstVC animated:YES];
    btn.selected = !btn.selected;
    if (btn.isSelected) {
        [btn setImage:[UIImage imageNamed:@"_26"] forState:UIControlStateSelected];
        
    }else {
    [btn setImage:[UIImage imageNamed:@"_22@3x"] forState:UIControlStateNormal];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
